home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 11.2 KB | 362 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawPart.h
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWPART_H
- #define DRAWPART_H
-
- // ----- Part Layer -----
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWPRTSCP_H
- #include "FWPrtScp.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRESFIL_H
- #include "FWResFil.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CFloatingWindow;
- class FW_CMenuEvent;
- class FW_CDropCommand;
- class FW_CPresentation;
-
- class CBaseShape;
- class CProxyShape;
- class CToolFrame;
- class CPaletteFrame;
- class CPatternFrame;
- class CDrawSelection;
- class FW_CGraphicContext;
- class CDrawLinkManager;
- class CShapeCollection;
- class CDrawPartContent;
-
- //========================================================================================
- // Defines
- //========================================================================================
-
- #define kContentAnnotationProp "Apple:Framework:Proposition:ContentAnnotation"
- #define kContentAnnotationValue "Apple:Framework:Value:ContentAnnotation"
-
- //========================================================================================
- // class CDrawPart
- //========================================================================================
-
- class CDrawPart : public FW_CEmbeddingPart, public FW_MEmbeddingPartScriptable
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CDrawPart)
-
- friend class CDrawLinkManager;
-
- //----------------------------------------------------------------------------------------
- // Initialization/Destruction
- //
- public:
- CDrawPart(ODPart* odPart);
- virtual ~ CDrawPart();
-
- virtual void ReleaseAll(Environment *ev);
- virtual void Initialize(Environment *ev);
-
- void InitializePalettes(Environment *ev);
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual void EmbeddedFrameRemoved(Environment *ev,
- FW_MProxy* proxy);
-
- virtual FW_Boolean DoMenu(Environment *ev,
- const FW_CMenuEvent& theMenuEvent);
- virtual FW_Boolean DoAdjustMenus(Environment *ev,
- FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- virtual FW_CFrame* NewFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage);
-
- virtual FW_CLinkManager* NewLinkManager(Environment *ev);
-
- virtual FW_CContent* NewPartContent(Environment* ev);
-
- virtual FW_CWindow* NewDocumentWindow(Environment* ev);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void ExternalizeAnnotations(Environment *ev, ODStorageUnit* storageUnit);
- void InternalizeAnnotations(Environment *ev, ODStorageUnit* storageUnit);
-
- void RemoveShapeFromPart(Environment* ev, CBaseShape* shape);
- void AddShapeToPart(Environment* ev, CBaseShape* shape);
-
- CBaseShape* WhichShape(Environment *ev,
- FW_CGraphicContext& gc,
- const FW_CMouseEvent& theMouseEvent,
- FW_Boolean hasToBeSelected) const;
-
- FW_Fixed GetPenSize() const;
- unsigned short GetRenderVerb() const;
-
- FW_CPoint GetDrawingSize() const;
-
- void CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
- void CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
- void SetRenderVerb(Environment* ev, unsigned short renderVerb);
-
- void GetFillColor(FW_CColor& color) const;
- void GetFrameColor(FW_CColor& color) const;
-
- void SetFillColor(Environment* ev, const FW_CColor& color);
- void SetFrameColor(Environment* ev, const FW_CColor& color);
-
- FW_CPattern GetFillPattern() const;
- FW_CPattern GetFramePattern() const;
-
- void SetFillPattern(Environment* ev, short newFillPatIndex);
- void SetFramePattern(Environment* ev, short newFramePatIndex);
-
- void UpdateAfterMove(Environment* ev);
-
- void SetTool(Environment* ev, unsigned short newTool);
- unsigned short GetTool() const;
-
- FW_CPattern GetPattern(short patIndex) const;
-
- void UpdateAllToolFacets(Environment *ev);
-
- FW_CPresentation* GetMainPresentation() const;
- FW_CPresentation* GetPalettePresentation() const;
- FW_CPresentation* GetPatternPresentation() const;
- FW_CPresentation* GetToolPresentation() const;
-
- FW_Boolean IsAutoGridOn() const;
-
- long GetProxyCount() const;
-
- CBaseShape* NewShape(Environment* ev, unsigned short shapeType);
-
- CDrawPartContent* GetDrawContent() const;
-
- //--- Persistent link support ---
- void DoPostCreate(Environment* ev); // MacApp forever!
- CBaseShape* FindShapeWithIndex(short extIndex);
-
- //--- Semantic Object ---
-
- virtual FW_CElementIterator* NewElementIterator(Environment* ev,
- FW_CPart* part,
- ODDescType elementType) const;
-
- virtual void DoAECreateElement(Environment* ev,
- FW_CPart* part,
- const FW_CAppleEvent& event,
- FW_CAppleEvent& reply);
- private:
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- short fNbEmbedded;
-
- FW_CFloatingWindow* fPaletteWindow;
- FW_CFloatingWindow* fPatternWindow;
- FW_CFloatingWindow* fToolsWindow;
-
- CToolFrame* fToolFrame;
- CPaletteFrame* fPaletteFrame;
- CPatternFrame* fPatternFrame;
-
- CDrawPartContent* fPartContent;
- FW_CPoint fDrawingSize;
-
- unsigned short fTool;
- FW_Fixed fCurrentPenSize;
- unsigned short fRenderVerb;
- FW_CColor fFillColor;
- FW_CColor fFrameColor;
- short fFillPatIndex;
- short fFramePatIndex;
-
- CDrawSelection* fDrawSelection; // Attention I don't own the selection the presentation is
-
- FW_CPresentation* fPalettePresentation;
- FW_CPresentation* fPatternPresentation;
- FW_CPresentation* fToolPresentation;
- FW_CPresentation* fMainPresentation;
- FW_CPresentation* fAlignObjectsPresentation;
-
- FW_CPattern fPatternTable[12];
-
- FW_Boolean fAutoGrid;
-
- ODCommandID fUnit;
- ODCommandID fArcUnit;
-
- FW_Boolean fPostCreated; // perform DoPostCreate only once
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetDrawContent
- //----------------------------------------------------------------------------------------
- inline CDrawPartContent* CDrawPart::GetDrawContent() const
- {
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetDrawingSize
- //----------------------------------------------------------------------------------------
- inline FW_CPoint CDrawPart::GetDrawingSize() const
- {
- return fDrawingSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::IsAutoGridOn
- //----------------------------------------------------------------------------------------
- inline FW_Boolean CDrawPart::IsAutoGridOn() const
- {
- return fAutoGrid;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPenSize
- //----------------------------------------------------------------------------------------
- inline FW_Fixed CDrawPart::GetPenSize() const
- {
- return fCurrentPenSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetRenderVerb
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetRenderVerb() const
- {
- return fRenderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetTool
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetTool() const
- {
- return fTool;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetMainPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetMainPresentation() const
- {
- return fMainPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPalettePresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
- {
- return fPalettePresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPatternPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
- {
- return fPatternPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetToolPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetToolPresentation() const
- {
- return fToolPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetPattern(short patIndex) const
- {
- FW_ASSERT(patIndex>=0 && patIndex<12);
- return fPatternTable[patIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFillColor(FW_CColor& color) const
- {
- color = fFillColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFrameColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFrameColor(FW_CColor& color) const
- {
- color = fFrameColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillPattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetFillPattern() const
- {
- return fPatternTable[fFillPatIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFramePattern
- //----------------------------------------------------------------------------------------
- inline FW_CPattern CDrawPart::GetFramePattern() const
- {
- return fPatternTable[fFramePatIndex];
- }
-
- #endif
-